package com.zhangyu.shadow.repair.delegate.setting;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.zhangyu.shadow.repair.R;
import com.zhangyu.shadow.repair.R2;

import butterknife.BindView;
import st.lib.base.delegate.ShadowDelegate;
import st.lib.base.util.utilcode.util.ScreenUtils;

/**
 * @author zhangyu
 * @date 2019/3/19
 */
public class VersionDelegate extends ShadowDelegate {
    public static VersionDelegate newInstance() {
        return new VersionDelegate();
    }

    @BindView(R2.id.webView)
    WebView mWebView;
    @BindView(R2.id.toolbar)
    Toolbar mToolbar;

    @Override
    public Object setLayout() {
        return R.layout.delegate_version;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        mToolbar.setTitle("版本历史");
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setSupportZoom(true); //设置可以支持缩放
        mWebView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
        String url;
        if (ScreenUtils.isPad(_mActivity)) {
            url = "http://www.tepth.com/help/JiaojieVersionP.htm";
        } else {
            url = "http://www.tepth.com/help/JiaojieVersionA.htm";
        }
        mWebView.loadUrl(url);
    }
}
